package config

import (
	"common/helper"
	"database/sql"
)

/*
活动开关配置
*/

const (
	ActiveType_FirstCharge_Bonus          = 1 //
	ActiveType_RepeatCharge_Bonus         = 2 //
	ActiveType_ProxyBonus_ByValidCounts   = 3
	ActiveType_ProxyBonus_ByDepositAmount = 4
	ActiveType_Accu_Deposit_Bonus         = 5
	ActiveType_DailyBet                   = 6
	ActiveType_WeekBet                    = 7
	ActiveType_WeekLost                   = 8
	ActiveType_WeekCcommi                 = 9
	ActiveType_WeekDeposit                = 10
	ActiveType_ProxyChildRunningReturn    = 12
	ActiveType_RechargeShare              = 13 //下级充值分成
	ActiveType_PiggyBank                  = 14
	ActiveType_TurnTable                  = 16 //转盘活动
	ActiveType_Max
)

type ActiveSwitchCfg struct {
	ActiveType  int    `db:"active_type" json:"active_type"`
	ActiveName  string `db:"active_name" json:"active_name"`
	Status      int    `db:"status" json:"status"`
	PopupSwitch int    `db:"popup_switch" json:"popup_switch"`
}

var G_ActiveSwitch []ActiveSwitchCfg

func ActiveSwitchCfgRemove() {
	G_ActiveSwitch = []ActiveSwitchCfg{}
}

func ActiveSwitchCfgSetRow(row *sql.Rows) {
	var tVal ActiveSwitchCfg
	var err error
	err = row.Scan(&tVal.ActiveType, &tVal.ActiveName, &tVal.Status, &tVal.PopupSwitch)
	if err != nil {
		helper.InfoLog("ActiveSwitchCfgSetRow,scan err")
		return
	}

	G_ActiveSwitch = append(G_ActiveSwitch, tVal)
}

/*
某活动是否开启
*/
func IsActiveOpen(activeType int) int {
	for _, value := range G_ActiveSwitch {
		if value.ActiveType == activeType {
			return value.Status
		}
	}

	return 1
}

func GetActiveSwitchCfg() []ActiveSwitchCfg {
	return G_ActiveSwitch
}
